#ifndef __Rect_hpp__
#define __Rect_hpp__

#include "Point2.hpp"

namespace ge {

//----------------------------------------------------------------------------//
// Rect< T >
//----------------------------------------------------------------------------//

GE_PACK template < class T >
class GE_PACKED Rect
{
 public:

     Point2< T > p1, p2;

     Rect( void )
     {
     }

     Rect( const T& _x1, const T& _y1, const T& _x2, const T& _y2 ) : p1( _x1, _y1 ), p2( _x2, _y2 )
     {
     }

     Rect( const Point2< T >& _p1, const Point2< T >& _p2 ) : p1( _p1 ), p2( _p2 )
     {
     }

     Rect& SetOrigin( const Point2< T >& _pt )
     {
          p1.Set( _pt );
          return *this;
     }

     Rect& SetOrigin( const T& _x, const T& _y )
     {
          p1.Set( _x, _y );
          return *this;
     }

     Rect& SetSize( const Point2< T >& _pt )
     {
          p2.Set( _pt );
          return *this;
     }

     Rect& SetSize( const T& _w, const T& _h )
     {
          p2.Set( p1.x + _w, p1.y + _h );
          return *this;
     }

     Rect& SetWidth( const T& _w )
     {
          p2.x = p1.x + _w;
          return *this;
     }

     Rect& SetHeight( const T& _h )
     {
          p2.y = p1.y + _h;
          return *this;
     }

     T Width( void ) const
     {
          return p2.x - p1.x;
     }

     T Height( void ) const
     {
          return p2.y - p1.y;
     }

     Point2< T > Size( void ) const
     {
          return p2 - p1;
     }

} GE_UNPACK;

typedef Rect< int > Recti;
typedef Rect< float > Rectf;

} // namespace ge

#endif//__Rect_hpp__
